LF-4056b Fix for language selector dropdown #3436
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When I migrated to the new
useLanguageOptions
hook in this PR:I completely missed that
components/Profile/Account
expected to see the options in a map format, not in the React Select Options array format expected bycomponents/InviteUser
andcomponents/Profile/EditUser
.The hook only returns the array shape, so the code that sets the
languagePreferenceOptionRef
no longer created the correct React Select option shape, and as a result the language became unselected when you saved a newlanguage_preference
.I also considered updating the hook to return either map or array depending on the calling component (i.e. to accept a parameter like
returnType = 'map' | 'array'
, but I thought it seemed cleaner to update the account code to work with the options array as the other two components do.Also in this PR:
null
ing of the selected language upon change which flashes the unselected state (you can still see it on app) -- maybe this had a purpose at some point (giving translations time to load or such maybe, according to comment?) but I certainly didn't see such a purpose now so I have deleted it. Therefore no more flash.t()
function from theuseLanguageOptions
hook when I updated the language dropdown options in LF-4056 Language selector needs to provide list of language in their native form #3416 (at which point they are no longer sent through i18n)Jira link: https://lite-farm.atlassian.net/browse/LF-4056?focusedCommentId=17638 (linking to comment describing the bug)
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: